/**a test class that takes expressions from console
 * and process them
 * 
 * @author locphan
 * @version 1.01
 */


import java.util.EmptyStackException;
import java.util.Scanner;


public class CalculatorTest
{
   public static void main(String[] args)
   {
      Scanner input = new Scanner(System.in);
      while(input.hasNextLine())
      {
         String line = input.nextLine();

         Calculator calc = new Calculator();

         System.out.println("\n" + "Original: "+line);
         
         try
         {
            String preprocess = calc.preProcess(line);
            System.out.println("Preprocessed: "+preprocess);
            
            System.out.println("Postfix: "+calc.toPostFix(preprocess));
            System.out.println("Result: "+calc.result());
         }
         catch(IllegalStateException e)
         {
            System.out.println("Syntax!");
         }
         catch(EmptyStackException e)
         {
            System.out.println("Parenthesis!");
         }
         
      }
      
      
   }
}
